//@Time : 2020/11/3 上午11:40
//@Author : bishisimo
package cmd

import (
	"context"
	"github.com/rs/zerolog/log"
	"github.com/spf13/cobra"
	"wormhole/pkg/clientx"
	"wormhole/protos/hole"
)

var stopCmd = &cobra.Command{
	Use:     "stop",
	Aliases: []string{""},
	Short:   "停止服务",
	Long:    ``,
	Run: func(cmd *cobra.Command, args []string) {
		c, err := clientx.NewLocalClient()
		if err != nil {
			log.Fatal().Err(err).Send()
		}
		_, err = c.Stop(context.Background(), new(hole.Empty))
		if err != nil {
			log.Fatal().Err(err).Msg("服务端未启动")
		}
	},
}

func init() {
	serverCmd.AddCommand(stopCmd)
}
